
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>检查项目费</title>
		<link rel="stylesheet" type="text/css" href="js/bootstarp-3.3.7/css/bootstrap.min.css"/>
		<script src="vendor/jquery/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstarp-3.3.7/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="js/bootstarp-table-1.11.1/bootstrap-table.min.css" />
		<script src="js/bootstarp-table-1.11.1/bootstrap-table.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js" type="text/javascript" charset="utf-8"></script>
			<script src="js/bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js" type="text/javascript" charset="utf-8"></script>
	<script>
			$(function() { //, headers: { 'x-requested-with': 'XMLHttpRequest' }
				$.ajaxSetup({
					crossDomain: true,
					xhrFields: {
						withCredentials: true
					}
				});
			});
		</script>
	<script type="text/javascript">
		$(function() {
			//var q1=	document.getElementById("qwert1");
			//var c1=	21,化验类.substr(0,1);
				$("table").bootstrapTable({
					url: "http://127.0.0.1:8099/Dzm_His_Inspectionfeeall",
					pagination: true,
					pageSize: 10,
					queryParams: queryParams,
					columns: [{ 
						field: 'ins_id',
						title: '序号',
						align: 'center',
					}, {
						field: 'inspection_name',
						title: '项目名称',
						align: 'center',
					}, {
						field: 'clas',
						title: '项目类别',
						align: 'center',
					}, {
						field: 'unit_price',
						title: '单价',
						align: 'center',
					}, {
						field: 'cost',
						title: '成本',
						align: 'center',
					}, {
						title: '操作',
						align: 'center',
						formatter: function(value, row, index) {
							return '<button onclick="delet(' + row.ins_id + ')" class="btn btn-danger glyphicon glyphicon-trash"></button>  <button onclick="upda(' + row.ins_id + ')" class="btn btn-info glyphicon glyphicon-edit"></button>'
						}
					}]

				})
})
		
			/**
	 * 下拉框赋值
	 */
//		$.getJSON("http://127.0.0.1:8099/Dzm_His_Inspectionfeexlk", function(data) {			
//			for(var i = 0; i < data.length; i++) {								
//				$("#clas").append("<option value='" + data[i].class_id + "'>" + data[i].clas + "</option>")	
//			}
//		})
		
		/**
		 * 删除
		 * @param {Object} ins_id
		 */
		function delet(ins_id) {
		$.ajax({
				type: "post",
				url: "http://127.0.0.1:8099/Dzm_His_Inspectionfeedele",
				data: "ins_id=" + ins_id,
				success: function(data) {
					alert("删除成功")
					$("table").bootstrapTable('refresh')
				}
		});		
		}
		
		
		
				/**
		 * 添加
		 */
		function add () {
			if($("#inspection_name2").val().trim().length==0||$("#class_id").val().trim().length==0||$("#unit_price").val().trim().length==""||$("#cost").val().trim().length==""||$("#unit").val().trim().length==""){
				alert("请把信息填写完整")
			}else{
			$.ajax({
				type: "post",
				url: "http://127.0.0.1:8099/Dzm_His_Inspectionfeeinsert",
				data:$("#for").serialize(),
				success: function(data) {
					$("#myModal").modal("hide")
					$("table").bootstrapTable('refresh')						
							}
			});
			}
		}
		
				/**
		 * 修改查询
		 * @param {Object} ins_id
		 */
		function upda (ins_id) {
			
			$("#myModal2").modal("show")
				$.ajax({
					type: "post",
					url: "http://127.0.0.1:8099/Dzm_His_Inspectionfeealls",
					data: "ins_id=" + ins_id,  				
					success: function(data) {
						alert(data.ins_id)
						$("#ins_id").val(data.ins_id);
						$("#inspection_name3").val(data.inspection_name);
						 var obj = $("#class_id3")[0].options;
						for(var i=0;i<obj.length;i++){
							
							if(obj[i].value.split(",")[0]==data.class_id){
								alert(obj[i].selected.length);
								obj[i].selected=true;
									alert(obj[i].selected);
								break;
							}
						}
			
						$("#unit_price3").val(data.unit_price);
						$("#cost3").val(data.cost);
						$("#unit3").val(data.unit);
					}
				});
		}
		
				/**
		 * 修改
		 */
		function up () {	
			alert(123)
			if($("#inspection_name3").val().trim().length==0||$("#class_id3").val().trim().length==0||$("#unit_price3").val().trim().length==""||$("#cost3").val().trim().length==0||$("#unit3").val().trim().length==0){
				alert("去把信息填写完整")
			}else{
				alert($("#for3").serialize())
			$.ajax({
				
					type: "post",
					url: "http://127.0.0.1:8099/Dzm_His_Inspectionfeeup",
					data:$("#for3").serialize(),
					success: function(data) {
						 
						$("#myModal2").modal("hide")
						$("table").bootstrapTable('refresh')
					}
				});
			}
		}
		
		
		
	
	
			function btn2() {
				$("#inspection_name2").val("");
				$("#clas").val("");
				$("#unit_price").val("");
				$("#cost").val("");
				$("#unit").val("");
				$("#myModal").modal("show");
			}
		
		function queryParams(Params) {
			return {
				'inspection_name': $("#inspection_name").val(),
			}
		}
	
		
		function select() {
			$("table").bootstrapTable('refresh')
		}
		
		</script>
	</head>
	<body>
		<div align="center"><br />
			<form class="form-inline">
				<div class="form-group"><br />
					<label for="exampleInputEmail2">项目名称：</label>
					<input type="text" class="form-control" id="inspection_name" name="inspection_name" placeholder="请输入项目名称">		
					<button type="button" class="btn btn-default glyphicon glyphicon-search" onclick="select()"></button>
					<button type="button" class="btn btn-primary glyphicon glyphicon-plus"  onclick="btn2()"></button>
				</div>
			</form>
		</div>
		<br />
		
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="myModalLabel">添加新的项目</h4>
					</div>
					<div class="modal-body">


					<form class="form-horizontal" id="for">
					 <div class="form-group">
    						<label for="inputEmail3" class="col-sm-3 control-label">项目名称：</label>
   								 <div class="col-sm-8">
     								 <input type="text" class="form-control" id="inspection_name2" name="inspection_name" placeholder="费用名称">
    							</div>
  					</div>
  					
  					<div class="form-group">
    						<label for="inputEmail3" class="col-sm-3 control-label">项目类别：</label>
   								 <div class="col-sm-8">
									<select class="form-control" id="class_id" name="clas">
										<option value="">请选择类别</option>
										<option value="22,化验类">化验类</option>
										<option value="21,拍片类">拍片类</option>
									</select>    							
   								 </div>
  					</div>
  					
  					<div class="form-group">
    						<label for="inputEmail3" class="col-sm-3 control-label">项目单价：</label>
   								 <div class="col-sm-8">
     								 <input type="text" class="form-control" id="unit_price" name="unit_price" placeholder="项目单价">
    							</div>
  					</div>
  					
  					<div class="form-group">
    						<label for="inputEmail3" class="col-sm-3 control-label">项目成本：</label>
   								 <div class="col-sm-8">
     								 <input type="text" class="form-control" id="cost" name="cost" placeholder="项目成本">
    							</div>
  					</div>
  					
  					<div class="form-group">
    						<label for="inputEmail3" class="col-sm-3 control-label">项目单位：</label>
   								 <div class="col-sm-8">
     								 <input type="text" class="form-control" id="unit" name="unit" placeholder="项目单位">
    							</div>
  					</div>


						

						</form>
						
						
					
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-danger glyphicon glyphicon-remove" data-dismiss="modal" onclick="close()"></button>
						<button type="button" class="btn btn-success glyphicon glyphicon-ok"  onclick="add()"></button>
					</div>
				</div>
			</div>
		</div>
		
		
		<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="myModalLabel">编辑检查项目</h4>
					</div>
					<div class="modal-body">


					<form class="form-horizontal" id="for3">
					 <div class="form-group">
					 	<input type="hidden" id="ins_id"  name="ins_id"/>
    						<label for="inputEmail3" class="col-sm-3 control-label">项目名称：</label>
   								 <div class="col-sm-8">
     								 <input type="text" class="form-control" id="inspection_name3" name="inspection_name" placeholder="费用名称">
    							</div>
  					</div>
  					
  					<div class="form-group">
    						<label for="inputEmail3" class="col-sm-3 control-label">项目类别：</label>
   								 <div class="col-sm-8">
									<select class="form-control" id="class_id3" name="clas">
										<option value="">请选择类别</option>
										<option  value="22,化验类">化验类</option>
										<option  value="21,拍片类">拍片类</option>
									</select>    							
   								 </div>
  					</div>
  					
  					<div class="form-group">
    						<label for="inputEmail3" class="col-sm-3 control-label">项目单价：</label>
   								 <div class="col-sm-8">
     								 <input type="text" class="form-control" id="unit_price3" name="unit_price" placeholder="项目单价">
    							</div>
  					</div>
  					
  					<div class="form-group">
    						<label for="inputEmail3" class="col-sm-3 control-label">项目成本：</label>
   								 <div class="col-sm-8">
     								 <input type="text" class="form-control" id="cost3" name="cost" placeholder="项目成本">
    							</div>
  					</div>
  					
  					<div class="form-group">
    						<label for="inputEmail3" class="col-sm-3 control-label">项目单位：</label>
   								 <div class="col-sm-8">
     								 <input type="text" class="form-control" id="unit3" name="unit" placeholder="项目单位">
    							</div>
  					</div>


						

						</form>
						
						
					
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-danger glyphicon glyphicon-remove" data-dismiss="modal" onclick="close()"></button>
						<button type="button" class="btn btn-success glyphicon glyphicon-ok"  onclick="up()"></button>
					</div>
				</div>
			</div>
		</div>
		
		
		
		<table class="table table-striped" >		
		</table>	
	</body>
</html>
